﻿using MediatR;
using Warehouse.API.Applcation.Command.WarehouseCommand;
using Warehouse.Domain;
using Warehouse.Infrstructre.Interface;
namespace Warehouse.API.Applcation.CommandHandlers.WarehouseCommandHndlers
{
    public class UpdateWarehouseCommandHandlers : IRequestHandler<UpdateWarehouseCommand, int>
    {
        private readonly IWarehouseRepository _warehouse;

        public UpdateWarehouseCommandHandlers(IWarehouseRepository warehouse)
        {
            _warehouse = warehouse;
        }

        public async Task<int> Handle(UpdateWarehouseCommand request, CancellationToken cancellationToken)
        {


            return await _warehouse.UpdateAsync(new Warehouseinfo() { WarehouseId = request.WarehouseId, WarehouseCode = request.WarehouseCode, WarehouseName = request.WarehouseName, RentalTime = request.RentalTime, WarehouseType = request.WarehouseType, Department = request.Department, IsDefaults = request.IsDefaults, IsDisable = request.IsDisable, Waddress = request.Waddress, Area = request.Area, Wcontact = request.Wcontact, Wphone = request.Wphone, Function = request.Function, UpdName = request.UpdName, UpdTime = request.UpdTime, AddName = request.AddName, AddTime = request.AddTime, office_id = request.office_id, user_id = request.user_id });

        }
    }
}
